<template>
  <div class="Mine">
    <div class="header">
      <div class="header-left">
        <i class="iconfont icon-saoyisao"></i>
      </div>
      <div class="header-center">
        <van-search shape="round" v-model="value" placeholder="搜索知乎内容" />
      </div>
      <div class="header-right">
        <i class="iconfont icon-Moon2"></i>
        <i class="iconfont icon-shezhi"></i>
        <i class="iconfont icon-xiaoxi"></i>
      </div>
    </div>
    <div class="block"></div>

    <div class="userinfo-wrapper">
      <div class="UIW-top" @click="login" v-show="noLogin">
        <div class="UIW-top-left">
          <div class="login-info">
            点我登录<i class="iconfont icon-arrow-right"></i>
          </div>
          <i class="iconfont icon-shouji"></i>
          <i class="iconfont icon-weixin"></i>
          <i class="iconfont icon-qq"></i>
        </div>
        <div class="UIW-top-right">
          <img src="@/assets/images/zhihu.png" alt="">
        </div>
      </div>

      <div class="uiw-top">
        <div class="uiw-top-left">
          <div class="touxiang">
            <img :src="Img">
          </div>
        </div>
      </div>

      <div class="UIW-bottom">
        <div class="UIW-bottom-left">
          <div class="num">0</div>
          <span class="tip">关注</span>
        </div>
        <div class="UIW-bottom-center">
          <div class="num">0</div>
          <span class="tip">收藏</span>
        </div>
        <div class="UIW-bottom-right">
          <div class="num">0</div>
          <span class="tip">最近浏览</span>
        </div>
      </div>
    </div>

    <div class="open-vip">
      <div class="ov-left">
        <div class="title">开通盐选会员</div>
        <van-swipe :autoplay="4000" vertical :show-indicators="false">
          <van-swipe-item>畅享 5000W+ 优质内容</van-swipe-item>
          <van-swipe-item>平均每位会员省 ￥1100+/年</van-swipe-item>
        </van-swipe>
      </div>
      <div class="ov-right">
        仅0.3元/天
      </div>
    </div>

    <div class="tool">
      <div class="icon-wrapper" v-for="(item,index) in iconImg" :key="index">
        <i class="iconfont" :class="item.url"></i>
        <div class="tool-name">{{item.name}}</div>
      </div>
    </div>
  </div>
  <TabBar />
</template>

<script setup>
import { ref, reactive,onBeforeMount } from 'vue'
import TabBar from '@/components/TabBar.vue'
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';

const route = useRoute()
const router = useRouter()

let isLogin = ref(false)
let noLogin = ref(true)
let Img = ref()

onBeforeMount(()=>{
  axios.post('http://localhost:3200/getImg',{
    username:route.query.username
  }).then(function(res){
    Img.value = res.data.Img
  })
})

const iconImg = reactive(
  [
    {
      url:'icon-wallet',
      name:'钱包'
    },
    {
      url:'icon-leaf',
      name:'社区共建'
    },
    {
      url:'icon-kefu',
      name:'帮助与客服'
    },
    {
      url:'icon-zhibo1',
      name:'直播'
    }
  ]
)

function login(){
  router.push('/login');
}
</script>

<style lang='less' scoped>
.Mine{
  width: 100%;
  height: calc(100vh - 53px);
  background: linear-gradient(0deg, #F5F5F5, #fff);
}
.header {
  display: flex;
  width: 100%;
  height: 54px;
  position: fixed;
  top: 0;
  left: 0;
  background: #fff;
  align-items: center;

  .iconfont {
    font-size: 24px;
    padding: 0 10px;
    color: rgba(112, 112, 112);
    font-weight: 1;
  }

  .hedaer-center {
    flex: 1;

    .van-search {
      width: 180px;

      .van-search__content {
        height: 20px;
      }
    }
  }

  .header-right {
    flex: 1;
    padding: 0 10px;

    .iconfont {
      font-size: 24px;
      padding: 0 10px;
      color: rgba(112, 112, 112);
      font-weight: 1;
    }
  }
}

.block {
  height: 54px;
}

.userinfo-wrapper {
  .UIW-top {
    position: relative;
    display: flex;
    margin: 0 20px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(112, 112, 112, 0.2);

    .UIW-top-left {
      height: 120px;
      width: 180px;
      font-size: 0.6rem;

      .login-info {
        height: 30px;
        line-height: 30px;
        font-weight: bold;
        color: rgba(52, 52, 52);
        padding: 30px 0 10px 0;

        i {
          display: inline-block;
          vertical-align: middle;
          margin-bottom: 6px;
          margin-left: 10px;
          font-size: 0.2rem;
        }
      }

      .iconfont {
        padding-right: 10px;
        font-size: 0.75rem;
      }

      .icon-shouji {
        color: rgba(0, 101, 254);
      }

      .icon-weixin {
        color: rgba(71, 211, 97);
      }

      .icon-qq {
        color: rgba(79, 199, 252);
      }
    }

    .UIW-top-right {
      position: absolute;
      right: -20px;

      img {
        height: 120px;
      }
    }
  }

  .UIW-bottom {
    display: flex;

    .UIW-bottom-left,
    .UIW-bottom-center,
    .UIW-bottom-right {
      flex: 1;
      padding-top: 15px;

      .num {
        text-align: center;
        font-weight: bold;
        font-size: 20px;
      }

      .tip {
        text-align: center;
        display: block;
        width: 100%;
        color: rgba(68, 68, 68);
        font-weight: 500;
        border-right: 1px solid rgba(112, 112, 112, 0.5);
      }
    }

    .UIW-bottom-right .tip:last-child {
      border: none;
    }
  }
}

.open-vip {
  display: flex;
  background-color: #FAE9D7;
  border-radius: 10px;
  width: 341px;
  margin: 10px 17px;
  height: 65px;
  padding: 15px 20px;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #78521C;

  .ov-left {
    display: flex;
    flex-direction: column;
    padding: 5px 0;
    font-weight: 700;

    .van-swipe {
      height: 16px;
      font-size: 13px;
      font-weight: normal;
      padding: 0 0;
      color: #D9AD6E;
    }

    .title {
      font-size: 15px;
      padding: 0 0 5px 0;
    }
  }

  .ov-right {
    width: 98px;
    height: 30px;
    background: linear-gradient(0deg, #F3BE70, #F6DFBB);
    text-align: center;
    line-height: 30px;
    border-radius: 20px;
    font-size: 14px;
  }
}

.tool{
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 341px;
  height: 70px;
  margin-left: 17px;
  background-color: #fff;
  border-radius: 10px;
  font-size: 14px;
  .icon-wrapper{
    text-align: center;
    .iconfont{
      font-size: 24px;
      font-weight: bold;
    }
  }
}
</style>